package com.barneyx.mshinfoplatform.entity.user;

import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.util.StrUtil;
import com.barneyx.mshinfoplatform.entity.enums.EPlatformType;
import com.barneyx.mshinfoplatform.service.user.IUserService;
import lombok.*;
import lombok.experimental.Accessors;

import javax.annotation.Resource;
import java.io.Serializable;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
@ToString
public class PlatformUserInfo implements Serializable {


    @Builder.Default
    private Boolean IsBind = false;

    private UserPlatformEntity PlatformUser;

    private EPlatformType Device;

    private UserEntity User;

    @Builder.Default
    private String Token = StpUtil.getTokenValue();


    public boolean getIsBind() {
        if (getPlatformUser() != null && getUser() != null) {
            return StrUtil.isAllNotBlank(getPlatformUser().getPhone(), getUser().getUserPhone());
        }
        return false;
    }


    public String getToken() {
        return StpUtil.getTokenValue();
    }
}
